<!DOCTYPE html>
<html>
<head>
    <script src="../../resources/js-test.js"></script>
</head>
<body onload="runTest()">
<input type="text" id="src">
<input type="text" id="dst">
<div id="console"></div>
<script>
description("This test verifies that content of input box could be restored in 'focus' event fired by drag-and-drop.");

var oldValue = "foo";

function runTest()
{
    var src = document.getElementById('src');
    src.value = "abc";
    var dst = document.getElementById('dst');

    function restoreValue()
    {
        oldValue = src.value;
        src.value = "abc";
    }
    dst.addEventListener("focus", restoreValue, false);

    src.select();
    eventSender.mouseMoveTo(src.offsetLeft + src.offsetWidth / 2, src.offsetTop + src.offsetHeight / 2);
    eventSender.mouseDown();
    eventSender.leapForward(1000);
    eventSender.mouseMoveTo(dst.offsetLeft + dst.offsetWidth / 2, dst.offsetTop + dst.offsetHeight / 2);
    eventSender.mouseUp();

    shouldBeEqualToString("oldValue", "");
    shouldBeEqualToString("src.value", "abc");
    shouldBeEqualToString("dst.value", "abc");
}
</script>
</body>
</html>
